import java.util.Scanner;

public class demo01 {
    //数字三角形
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[][] arr=new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                arr[i][j]=sc.nextInt();
            }
        }
        for (int i = arr.length-2; i >=0 ; i--) {
            for (int j = 0; j <= i; j++) {
                int num=Math.max(arr[i+1][j],arr[i+1][j+1]);
                arr[i][j]+=num;
            }
        }
        System.out.println(arr[0][0]);
    }
}
